/**
 * Copyright © 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
 */
package com.jeeplus.modules.tbuildinginfo.service;

import java.util.List;
import java.util.Map;

import com.jeeplus.common.json.AjaxJson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.jeeplus.core.persistence.Page;
import com.jeeplus.core.service.CrudService;
import com.jeeplus.modules.tbuildinginfo.entity.TBuildingInfo;
import com.jeeplus.modules.tbuildinginfo.mapper.TBuildingInfoMapper;

/**
 * 楼宇列表Service
 * @author pr
 * @version 2022-04-18
 */
@Service
@Transactional(readOnly = true)
public class TBuildingInfoService extends CrudService<TBuildingInfoMapper, TBuildingInfo> {

	@Autowired
	private TBuildingInfoMapper tBuildingInfoMapper;

	public TBuildingInfo get(String id) {
		return super.get(id);
	}
	
	public List<TBuildingInfo> findList(TBuildingInfo tBuildingInfo) {
		return super.findList(tBuildingInfo);
	}
	
	public Page<TBuildingInfo> findPage(Page<TBuildingInfo> page, TBuildingInfo tBuildingInfo) {
		return super.findPage(page, tBuildingInfo);
	}

	public AjaxJson getBuildingInfoAllRegion(){
		List<Map<String, Object>> buildingInfoAllRegion = tBuildingInfoMapper.getBuildingInfoAllRegion();
		if (buildingInfoAllRegion.size() > 0 ) {
			return AjaxJson.success().put("page",buildingInfoAllRegion);
		}
		return AjaxJson.success("查询无结果，请重试！");
	}

	public AjaxJson getAllBuildingName() {
		List<TBuildingInfo> allBuildingName = tBuildingInfoMapper.getAllBuildingName();
		if (allBuildingName.size() > 0 ) {
			return AjaxJson.success().put("page",allBuildingName);
		}
		return AjaxJson.success("查询无结果，请重试！");
	}
	
	@Transactional(readOnly = false)
	public void save(TBuildingInfo tBuildingInfo) {
		super.save(tBuildingInfo);
	}
	
	@Transactional(readOnly = false)
	public void delete(TBuildingInfo tBuildingInfo) {
		super.delete(tBuildingInfo);
	}

	@Transactional(readOnly = false)
	public void addContractedCustomer(String id) {
		tBuildingInfoMapper.addContractedCustomer(id);
	}

	@Transactional(readOnly = false)
	public void removeContractedCustomer(String id) {
		tBuildingInfoMapper.removeContractedCustomer(id);
	}

}